#ifndef mW_minheap_include
#define mW_minheap_include


#include <stdlib.h>
#include <stdio.h>
#include "error.h"


typedef struct _mW_minheap_item
{

	void * data;
	struct _mW_minheap_item * left;
	struct _mW_minheap_item * right;
	struct _mW_minheap_item * parent;
	
} mW_minheap_item;



typedef struct _mW_minheap
{
	
	int size;
	int (* comparison_function) (mW_minheap_item *, mW_minheap_item *);
	mW_minheap_item * top;

} mW_minheap;



mW_minheap * mW_minheap_create (void * comparison_function);

int mW_minheap_delete_top (mW_minheap * minheap);
int mW_minheap_destroy (mW_minheap * minheap);
int mW_minheap_destroy_item (mW_minheap_item * minheap_item);


int    mW_minheap_get_size (mW_minheap * minheap);
void * mW_minheap_get_top (mW_minheap * minheap);

int mW_minheap_insert (mW_minheap * heap, void * data);

int mW_minheap_upheap (mW_minheap * heap, mW_minheap_item * minheap_item);
int mW_minheap_downheap (mW_minheap * minheap, mW_minheap_item * minheap_item);

void * mW_minheap_search (mW_minheap * minheap, void * data, int (* search_function) (void *, void *));
void * mW_minheap_search_item (mW_minheap_item * minheap_item, void * data, int (* search_function) (void *, void *));


void mW_minheap_debug_item (mW_minheap_item * minheap_item, int depth);
void mW_minheap_debug (mW_minheap * minheap);


#endif // mW_minheap_include
